<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP '008_datagrid.jsp' starting page</title>

		<%@include file="/WEB-INF/jsp/public/commons.jspf"%>
		<link rel="stylesheet"
			href="<%=path%>/js/kindeditor-4.1.7/themes/default/default.css" />
		<link rel="stylesheet"
			href="<%=path%>/js/kindeditor-4.1.7/plugins/code/prettify.css" />
		<link rel="stylesheet" href="<%=path%>/css/kpointAdd.css" />
		<script charset="utf-8"
			src="<%=path%>/js/kindeditor-4.1.7/kindeditor.js"></script>
		<script charset="utf-8"
			src="<%=path%>/js/kindeditor-4.1.7/lang/zh_CN.js"></script>
		<script charset="utf-8"
			src="<%=path%>/js/kindeditor-4.1.7/plugins/code/prettify.js"></script>
		<script charset="utf-8" src="<%=path%>/js/kpoint/add.js"></script>
		<script type="text/javascript">

		KindEditor.ready(function(K) {
			var editor1 = K.create('#description', {
				cssPath : '<%=basePath%>js/kindeditor-4.1.7/plugins/code/prettify.css',
				uploadJson : '<%=basePath%>js/kindeditor-4.1.7/jsp/upload_json.jsp',
				fileManagerJson : '<%=basePath%>js/kindeditor-4.1.7/jsp/file_manager_json.jsp',
				allowFileManager : true,
			});
			prettyPrint();


			//表单提交
			$("#btn1").click(function(){

				if ($('#myform').form('validate')){
					//同步textarea的数据
					editor1.sync();


					$.ajax({
						type: 'post' ,
						url:'kpoint_add.action',
						cache:false ,
						data:$('#myform').serialize() ,
						dataType:'json' ,
						success:function(result){
							// 提示信息
							parent.$.messager.show({
								title:result.status , 
								msg:result.message
							});
							parent.closeWin();
							
						} ,
						error:function(result){
							$.messager.show({
								title:result.status , 
								msg:result.message
							});
						}
					});

					//$("#myform").submit();
				}
			});
		});

		$(function(){

			/*初始化导航*/
			$("#nav").combotree( {
				url : 'navigation_listJsonLeft.action',
				valueField : 'name', //数据表格要有主键	
				textField : 'name'
			});

			/**
			 * 	对于form表单的验证 
			 */
			//数值验证组件 
			// 自定义的校验器
			$.extend($.fn.validatebox.defaults.rules,
					{
						midLength : {
							validator : function(value, param) {
								return value.length >= param[0]
										&& value.length <= param[1];
							},
							message : ''
						}
					});

			//数值验证组件 
			$('#period').numberbox( {
				min : 0,
				max : 200,
				required : true,
				missingMessage : '学时必填!',
				precision : 0
			});


			
		});
</script>
		<script type="text/javascript">
	
</script>
	</head>

	<body>


		<form id="myform" action="kpoint_add.action" method="post">
			<table>
				<tr>
					<td>
						知识点名:
					</td>
					<td>
						<input type="text" name="name" id="name"
							class="easyui-validatebox" required=true
							validType="midLength[1,100]" missingMessage="知识点名必填!"
							invalidMessage="必须在100个字符以内!" />
					</td>
				</tr>
				<tr>
					<td>
						所属分类:
					</td>
					<td>
						<input name="navigation.id" id="nav" required=true
							missingMessage="分类必选!" />
					</td>
				</tr>
				<tr>

					<td>
						定义:
					</td>
					<td>
						<textarea type="text" name="definition" id="definition" style="resize:none"
							class="easyui-validatebox" required=true
							validType="midLength[1,300]" missingMessage="定义必填!"
							invalidMessage="定义必须在250个字符以内!"></textarea>
					</td>
				</tr>
				<tr>
					<td>
						难度:
					</td>
					<td>
						<select id="defficulty" name="defficulty" style="width: 200px;"
							name="difficulty">
							<option value="1">
								非常简单
							</option>

							<option value="2">
								简单
							</option>

							<option value="3">
								中等
							</option>

							<option value="4">
								困难
							</option>

							<option value="5">
								非常困难
							</option>
						</select>
					</td>
				</tr>

				<tr>
					<td>
						目标:
					</td>
					<td>
						<input type="radio" name="goal" checked="checked" value="1" />
						了解
						<input type="radio" name="goal" value="2" />
						掌握
						<input type="radio" name="goal" value="3" />
						应用
					</td>
				</tr>

				<tr>
					<td>
						学时:
					</td>
					<td>
						<input id="period" type="text" name="period" />
					</td>
				</tr>

				<tr>
					<td>
						参考资料：
					</td>
					<td>
						<input id="referenceIds" type="hidden" name="referenceIds" value="" />
						<div id="referenceTip">
						</div>
						<a id="referenceBtn" class="easyui-linkButton" iconCls='icon-add'>添加参考资料</a>
						<div id="referenceWin" title="请选择参考资料">
							<table id="referenceDataGrid"></table>
						</div>
					</td>
				</tr>


				<tr>
					<td>
						父类知识点:
					</td>
					<td>
						<input id="parentKIds" type="hidden" name="parentKIds" value="" />
						<div id="parentKTip">
						</div>
						<a id="parentKBtn" class="easyui-linkButton" iconCls='icon-add'>添加父类知识点</a>
						<div id="parentKWin" title="请选择父类知识点">
							<table id="parentKDataGrid"></table>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						前导知识点:
					</td>
					<td>
						<input id="preKIds" type="hidden" name="preKIds" value="" />
						<div id="preKTip">
						</div>
						<a id="preKBtn" class="easyui-linkButton" iconCls='icon-add'>添加前导知识点</a>
						<div id="preKWin" title="请选择前导类知识点">
							<table id="preKDataGrid"></table>
						</div>
					</td>
				</tr>

				<tr>
					<td>
						描述:
					</td>
					<td>
						<textarea name="description" id="description" cols="50" rows="8"
							style="width: 700px; height: 200px; visibility: hidden;"
							class="easyui-validatebox" missingMessage="描述必填!">
							</textarea>
					</td>
				</tr>
				<tr align="center">
					<td colspan="2">
						<a id="btn1" class="easyui-linkbutton">确定</a>
						<a id="btn2" class="easyui-linkbutton">关闭</a>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
